﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using AutoFacUtils;
using FluentValidation;
using CashFlow.ShopManage.Models.User;
using CashFlow.ShopManage.Service;
using CashFlow.ShopManage.Common;

namespace CashFlow.ShopManage.Validator.User
{
    public class UpdateShopManagerLevelPercentModelValidator
        : AbstractValidator<UpdateShopManagerLevelPercentModel>
    {
        public UpdateShopManagerLevelPercentModelValidator()
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(x => x.UserId).Must(x => ValidatorTool.IsUserBelongsMyShop(x))
                .WithMessage("非法UserId");
            RuleFor(x => x.Percent).Must(x =>
            {
                if (x == 0)
                {
                    return true;
                }
                else
                {
                    return MyCommonTool.IsIllegalShopManagerLevelPercent(x);
                }
            }).WithMessage("非法的ShopManagerLevelPercent");
        }
    }
}